package com.kingschan.jeasytag;

import java.io.UnsupportedEncodingException;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONArray;
import org.json.JSONException;

import com.kingschan.util.web.ServletUtil;
/**
 * Carry http request data
 * @author kingschan
 *date:2013-6-27
 */
public final class HttpQueryBean {
	public HttpQueryBean(HttpServletRequest p_request,HttpServletResponse p_response) throws JSONException, UnsupportedEncodingException{
		this.request=p_request;
		this.response=p_response;
		this.httpargs=ServletUtil.getParameterMap(p_request);
		this.condition=this.httpargs.containsKey("filter")?new JSONArray(java.net.URLDecoder.decode(this.httpargs.get("filter"), "utf-8")):null;
		this.metadate=this.httpargs.containsKey("meta")?new JSONArray(java.net.URLDecoder.decode(this.httpargs.get("meta"), "utf-8")):null;
		this.pageindex=this.httpargs.containsKey("page")?new Integer(this.httpargs.get("page")):null;
		this.pagesize=this.httpargs.containsKey("rows")?new Integer(this.httpargs.get("rows")):null;
		this.serialization=this.httpargs.containsKey("target")?this.httpargs.get("target"):null;
	}

	private Map<String,String> httpargs;
	
	private String serialization;
	
	private Integer pageindex;
	
	private Integer pagesize;
	
	private JSONArray metadate;
	
	private JSONArray condition;
	
	private HttpServletRequest request;
	
	private HttpServletResponse response;
	/**
	 * get http request args
	 * @return
	 */
	public Map<String, String> getHttpargs() {
		return httpargs;
	}
	/**
	 * get Serialization id
	 * @return
	 */
	public String getSerialization() {
		return serialization;
	}

	public Integer getPageindex() {
		return pageindex;
	}

	public Integer getPagesize() {
		return pagesize;
	}

	public JSONArray getMetadate() {
		return metadate;
	}

	public JSONArray getCondition() {
		return condition;
	}

	public HttpServletRequest getRequest() {
		return request;
	}

	public HttpServletResponse getResponse() {
		return response;
	}

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	public void setHttpargs(Map<String, String> httpargs) {
		this.httpargs = httpargs;
	}

	public void setSerialization(String serialization) {
		this.serialization = serialization;
	}

	public void setPageindex(Integer pageindex) {
		this.pageindex = pageindex;
	}

	public void setPagesize(Integer pagesize) {
		this.pagesize = pagesize;
	}

	public void setMetadate(JSONArray metadate) {
		this.metadate = metadate;
	}

	public void setCondition(JSONArray condition) {
		this.condition = condition;
	}

	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}

	public void setResponse(HttpServletResponse response) {
		this.response = response;
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

	
	
	
}
